package com.compass.mobile.widget

import android.content.Context
import androidx.leanback.widget.ItemBridgeAdapter
import androidx.leanback.widget.ObjectAdapter
import com.compass.mobile.callback.OnItemClickListener

/**
 * Description： 自定义BridgeAdapter实现item点击事件
 * Date:2024/5/21 14:58
 */
class MyBridgeAdapter(
    private val mContext: Context,
    adapter: ObjectAdapter,
    private val onItemClickListener: OnItemClickListener?
) :
    ItemBridgeAdapter() {
    init {
        super.setAdapter(adapter)
    }

    public override fun onBind(viewHolder: ViewHolder) {
        // 设置宽高比
        viewHolder.itemView.setOnClickListener {
            onItemClickListener?.onItemClick(viewHolder.layoutPosition,viewHolder.itemView)

        }
    }

    public override fun onUnbind(viewHolder: ViewHolder) {
        // 清理资源
    }
}
